package com.open.capacity.answer.controller;

import com.open.capacity.answer.service.AnswerService;
import com.open.capacity.common.model.Answer;
import com.open.capacity.common.model.Course;
import com.open.capacity.common.web.PageResult;
import com.open.capacity.common.web.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/answer")
@Api(tags = "答疑管理")
public class AnswerController {

    @Autowired
    private AnswerService answerService;

    // 模糊查询疑问
    @PostMapping("/getSelectAnswers")
    @ApiOperation(value = "模糊查询疑问")
    public PageResult<Answer> getSelectAnswers(@RequestParam Map<String, Object> params){
        return answerService.getSelectAnswers(params);
    }

    // 添加疑问
    @PostMapping("/addAnswer")
    @ApiOperation(value = "添加疑问")
    public Result addAnswer(@RequestBody Answer answer){
        return answerService.addAnswer(answer);
    }

    // 修改疑问
    @PostMapping("/updateAnswer")
    @ApiOperation(value = "修改疑问")
    public Result updateAnswer(@RequestBody Answer answer){
        return answerService.updateAnswer(answer);
    }

    // 删除疑问
    @DeleteMapping("/delAnswer/{id}")
    @ApiOperation(value = "删除疑问")
    public Result delAnswer(@PathVariable("id") int id){
        return answerService.delAnswer(id);
    }

}
